<!DOCTYPE html>
<html>
    <head>
        <title>Pivot Demo</title>
        <!-- external libs from cdnjs -->
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>

        <!-- PivotTable.js libs from ../dist -->
        <link rel="stylesheet" type="text/css" href="../dist/pivot.css">
        <script type="text/javascript" src="../dist/pivot.js"></script>
        <style>
            body {font-family: Verdana;}
        </style>

        <!-- for examples only! script to show code to user -->
        <script type="text/javascript" src="show_code.js"></script>
    </head>
    <body>
        <script type="text/javascript">
    // This example shows pivot() with a sum() aggregator
    // with custom formatting (no digits after decimal)

    $(function(){

        var sum = $.pivotUtilities.aggregatorTemplates.sum;
        var numberFormat = $.pivotUtilities.numberFormat;
        var intFormat = numberFormat({digitsAfterDecimal: 0});

        $("#output").pivot(
            [
                {color: "blue", shape: "circle", value: 1},
                {color: "red", shape: "triangle", value: 2},
                {color: "blue", shape: "circle", value: 3},
                {color: "red", shape: "triangle", value: 4}
            ],
            {
                rows: ["color"],
                cols: ["shape"],
                aggregator: sum(intFormat)(["value"])
            }
        );
     });
        </script>

        <p><a href="index.html">&laquo; back to PivotTable.js examples</a></p>

        <div id="output" style="margin: 30px;"></div>

    </body>
</html>
